package com.yyplatform.frontend.infra.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yyplatform.frontend.infra.exception.ErrorCode;
import com.yyplatform.frontend.infra.exception.ServiceException;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class JsonUtils {

    public static String toJsonString(Object object) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(object);
        } catch (JsonProcessingException e) {
            log.error("json processiong excetion", e);
            throw ServiceException.of(ErrorCode.INTERNAL_SERVER_ERROR);
        }
    }


}
